
const _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault');

exports.__esModule = true;
exports.default = void 0;

const _babelHelperVueJsxMergeProps = _interopRequireDefault(require('@vue/babel-helper-vue-jsx-merge-props'));

const _extends2 = _interopRequireDefault(require('@babel/runtime/helpers/extends'));

const _utils = require('../utils');

const _functional = require('../utils/functional');

const _event = require('../utils/dom/event');

// Utils
const _createNamespace = (0, _utils.createNamespace)('overlay');
const createComponent = _createNamespace[0];
const bem = _createNamespace[1];

function preventTouchMove(event) {
  (0, _event.preventDefault)(event, true);
}

function Overlay(h, props, slots, ctx) {
  const style = (0, _extends2.default)({
    zIndex: props.zIndex,
  }, props.customStyle);

  if ((0, _utils.isDef)(props.duration)) {
    style.animationDuration = `${props.duration}s`;
  }

  return h('transition', {
    attrs: {
      name: 'van-fade',
    },
  }, [h('div', (0, _babelHelperVueJsxMergeProps.default)([{
    directives: [{
      name: 'show',
      value: props.show,
    }],
    style,
    class: [bem(), props.className],
    on: {
      touchmove: props.lockScroll ? preventTouchMove : _utils.noop,
    },
  }, (0, _functional.inherit)(ctx, true)]), [slots.default == null ? void 0 : slots.default()])]);
}

Overlay.props = {
  show: Boolean,
  zIndex: [Number, String],
  duration: [Number, String],
  className: null,
  customStyle: Object,
  lockScroll: {
    type: Boolean,
    default: true,
  },
};

const _default = createComponent(Overlay);

exports.default = _default;
